﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity.Migrations;
using Portfolio.DataModels;

namespace Portfolio.Data
{
    public static class Seeder
    {
        public static void Seed(
            ApplicationDbContext db,
            bool seedProjects = true,
            bool seedPosts = true
            )
        {
            if (seedProjects)
            {
                //seed Projects
                db.Projects.AddOrUpdate(
                    p => p.Title,
                    new Project { Title = "Journey", Description = "A voyage", Image = "http://i.telegraph.co.uk/multimedia/archive/01622/space-hubble-2010_1622267i.jpg" },
                    new Project { Title = "Makers", Description = "Building stuff", Image = "http://wjhaleconstruction.com/wp-content/uploads/2013/07/construction-tools.jpg" },
                    new Project { Title = "Food", Description = "Best Meals", Image = "http://s.hswstatic.com/gif/easy-weeknight-meals-blt.jpg" }

                    );
                db.SaveChanges();
            }
            if (seedPosts)
            {
                //seed Posts
                db.Posts.AddOrUpdate(
                    p => p.Heading,
                    new Post { Heading = "Too Long to Walk", Comment = "There is no way I'd do this again without a car!", ProjectId = 1 },
                    new Post { Heading = "Making the stuff, doing the deed", Comment = "That one very small step to making a new project", ProjectId = 2 },
                    new Post { Heading = "Best eats!", Comment = "I love the way this food looks and tastes", ProjectId = 3 }
                    );
                db.SaveChanges();
            }

        }
    }
}
